library("ggplot2")
library("dplyr")
library("readr")
library("tidyverse")
library("bomrang")
`?`(bomrang)
`?`(get_current_weather)
sydney_weather = bomrang::get_current_weather("Sydney")
dplyr::glimpse(sydney_weather)
## Rows: 144
## Columns: 35
## $ sort_order <int> 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14…
## $ wmo <int> 94768, 94768, 94768, 94768, 94768, 94768, 94768,…
## $ full_name <chr> "Sydney - Observatory Hill", "Sydney - Observato…
## $ history_product <chr> "IDN60801", "IDN60801", "IDN60801", "IDN60801", …
## $ local_date_time <chr> "26/01:30pm", "26/01:00pm", "26/12:30pm", "26/12…
## $ local_date_time_full <dttm> 2020-08-26 13:30:00, 2020-08-26 13:00:00, 2020-…
## $ aifstime_utc <dttm> 2020-08-26 03:30:00, 2020-08-26 03:00:00, 2020-…
## $ lat <dbl> -33.8607, -33.8607, -33.8607, -33.8607, -33.8607…
## $ lon <dbl> 151.205, 151.205, 151.205, 151.205, 151.205, 151…
## $ apparent_t <dbl> 15.4, 15.6, 16.1, 14.9, 12.5, 10.5, 8.9, 8.2, 6.…
## $ cloud <chr> "-", "-", "-", "-", "-", "-", "-", "-", "-", "-"…
## $ cloud_base_m <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, …
## $ cloud_oktas <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, …
## $ cloud_type <chr> "-", "-", "-", "-", "-", "-", "-", "-", "-", "-"…
## $ cloud_type_id <lgl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, …
## $ delta_t <dbl> 8.4, 8.0, 7.6, 7.1, 5.5, 5.0, 4.5, 4.0, 3.7, 3.2…
## $ gust_kmh <lgl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, …
## $ gust_kt <lgl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, …
## $ air_temp <dbl> 19.4, 18.7, 18.3, 17.4, 15.6, 14.1, 13.2, 12.5, …
## $ dewpt <dbl> 0.4, 0.3, 1.3, 1.4, 3.7, 2.7, 3.0, 3.5, 2.4, 2.6…
## $ press <dbl> 1027.4, 1027.8, 1028.5, 1029.0, 1029.4, 1029.9, …
## $ press_msl <dbl> 1027.4, 1027.8, 1028.5, 1029.0, 1029.4, 1029.9, …
## $ press_qnh <dbl> 1027.4, 1027.8, 1028.5, 1029.0, 1029.4, 1029.9, …
## $ press_tend <chr> "-", "-", "-", "-", "-", "-", "-", "-", "-", "-"…
## $ rain_trace <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, …
## $ rel_hum <int> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, …
## $ sea_state <chr> "-", "-", "-", "-", "-", "-", "-", "-", "-", "-"…
## $ swell_dir_worded <chr> "-", "-", "-", "-", "-", "-", "-", "-", "-", "-"…
## $ swell_height <lgl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, …
## $ swell_period <lgl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, …
## $ vis_km <chr> "-", "-", "-", "-", "-", "-", "-", "-", "-", "-"…
## $ weather <chr> "-", "-", "-", "-", "-", "-", "-", "-", "-", "-"…
## $ wind_dir <chr> "W", "W", "ESE", "WNW", "W", "WNW", "WNW", "WNW"…
## $ wind_spd_kmh <int> 11, 6, 2, 4, 9, 11, 15, 15, 17, 20, 19, 17, 19, …
## $ wind_spd_kt <int> 6, 3, 1, 2, 5, 6, 8, 8, 9, 11, 10, 9, 10, 11, 10…
ggplot(data = sydney_weather, aes(x = local_date_time_full, y = air_temp)) + geom_line()
2.2.1 Exercises
get_current_weather("Melbourne")
## --- Australian Bureau of Meteorology (BOM) Data Resource ---
## (Original Request Parameters)
## Station: MELBOURNE AIRPORT [086282]
## Location: lat: -37.6655, lon: 144.8321
## Measurement / Origin: All / Current
## Timespan: 1970 -- 2020 [50 years]
## ---------------------------------------------------------------
## sort_order wmo full_name history_product local_date_time
## 1: 0 94866 Melbourne Airport IDV60801 26/01:30pm
## 2: 1 94866 Melbourne Airport IDV60801 26/01:00pm
## 3: 2 94866 Melbourne Airport IDV60801 26/12:30pm
## 4: 3 94866 Melbourne Airport IDV60801 26/12:00pm
## 5: 4 94866 Melbourne Airport IDV60801 26/11:30am
## ---
## 140: 139 94866 Melbourne Airport IDV60801 23/04:00pm
## 141: 140 94866 Melbourne Airport IDV60801 23/03:30pm
## 142: 141 94866 Melbourne Airport IDV60801 23/03:00pm
## 143: 142 94866 Melbourne Airport IDV60801 23/02:30pm
## 144: 143 94866 Melbourne Airport IDV60801 23/02:00pm
## local_date_time_full aifstime_utc lat lon apparent_t
## 1: 2020-08-26 13:30:00 2020-08-26 03:30:00 -37.6655 144.8321 9.8
## 2: 2020-08-26 13:00:00 2020-08-26 03:00:00 -37.6655 144.8321 9.5
## 3: 2020-08-26 12:30:00 2020-08-26 02:30:00 -37.6655 144.8321 11.8
## 4: 2020-08-26 12:00:00 2020-08-26 02:00:00 -37.6655 144.8321 10.0
## 5: 2020-08-26 11:30:00 2020-08-26 01:30:00 -37.6655 144.8321 8.5
## ---
## 140: 2020-08-23 16:00:00 2020-08-23 06:00:00 -37.6655 144.8321 4.4
## 141: 2020-08-23 15:30:00 2020-08-23 05:30:00 -37.6655 144.8321 2.1
## 142: 2020-08-23 15:00:00 2020-08-23 05:00:00 -37.6655 144.8321 3.1
## 143: 2020-08-23 14:30:00 2020-08-23 04:30:00 -37.6655 144.8321 2.8
## 144: 2020-08-23 14:00:00 2020-08-23 04:00:00 -37.6655 144.8321 3.8
## cloud cloud_base_m cloud_oktas cloud_type cloud_type_id delta_t
## 1: Partly cloudy 1320 4 Stratocumulus 6 4.7
## 2: Partly cloudy 1140 3 Cumulus 8 3.8
## 3: Mostly clear 1050 2 Cumulus 8 4.4
## 4: Partly cloudy 1000 5 - 34 4.0
## 5: Mostly clear 960 2 Cumulus 8 3.7
## ---
## 140: Mostly cloudy 720 6 Stratocumulus 6 2.0
## 141: Mostly clear 480 2 Stratus 7 1.3
## 142: Mostly cloudy 300 7 - 38 1.7
## 143: Mostly clear 660 1 Cumulus 8 2.1
## 144: Mostly clear 660 2 Stratocumulus 6 1.9
## gust_kmh gust_kt air_temp dewpt press press_msl press_qnh press_tend
## 1: 20 11 13.7 3.2 1028.4 1028.4 1028.3 -
## 2: 13 7 12.5 4.1 1029.0 1029.0 1028.8 -
## 3: 15 8 13.8 4.2 1029.6 1029.6 1029.4 -
## 4: 15 8 13.0 4.2 1030.2 1030.2 1030.0 F
## 5: 13 7 12.0 3.7 1030.7 1030.7 1030.5 -
## ---
## 140: 33 18 9.3 4.9 1014.0 1014.0 1013.9 -
## 141: 44 24 8.7 5.9 1013.8 1013.8 1013.7 -
## 142: 37 20 9.1 5.4 1013.6 1013.6 1013.5 R
## 143: 41 22 9.9 5.3 1013.2 1013.2 1013.1 -
## 144: 35 19 9.7 5.6 1013.1 1013.1 1013.0 -
## rain_trace rel_hum sea_state swell_dir_worded swell_height swell_period
## 1: 0.0 NA - - NA NA
## 2: 0.0 NA - - NA NA
## 3: 0.0 NA - - NA NA
## 4: 0.0 NA - - NA NA
## 5: 0.0 NA - - NA NA
## ---
## 140: 2.0 NA - - NA NA
## 141: 2.0 NA - - NA NA
## 142: 1.6 NA - - NA NA
## 143: 1.6 NA - - NA NA
## 144: 1.6 NA - - NA NA
## vis_km weather wind_dir wind_spd_kmh wind_spd_kt
## 1: 10 - W 13 7
## 2: 10 - SW 9 5
## 3: 10 - NNW 4 2
## 4: 30 Fine WSW 9 5
## 5: 10 - SW 11 6
## ---
## 140: 10 - SSW 20 11
## 141: 10 Showers SSW 30 16
## 142: 20 Showers SW 26 14
## 143: 10 - SSW 32 17
## 144: 10 - SSW 26 14
mel_weather = bomrang::get_current_weather("Melbourne")
ggplot(data = mel_weather, aes(x = local_date_time_full, y = air_temp)) + geom_line()
ggsave(filename = "2.2.1 exercise.png")
# plotting wind speed in Melbourne
ggplot(data = mel_weather, aes(x = local_date_time_full, y = wind_spd_kmh)) + geom_line() +
labs(x = "Local Date", y = "Wind Speed / kmh") + theme_light()
write_csv(mel_weather, "mel_weather")
2.2.2
library("plotly")
myplot = ggplot(data = sydney_weather, aes(x = local_date_time_full, y = air_temp)) +
geom_line()
plotly::ggplotly(myplot)